export default {
    data() {
        return {

        }
    },
    filters: {
        addNum(item) {
            let num = 0
            item.forEach(i => {
                num += i.buyNum
            });
            return num;
        }
    },
    methods: {
        // 实现格式化时间
        $dataFormat(time, type) {
            let date = new Date(time);
            let year = date.getFullYear(),
                month = date.getMonth() + 1,
                day = date.getDate(),
                h = date.getHours(),
                m = date.getMinutes(),
                s = date.getMinutes();
            month = month < 10 ? `0${month}` : month
            day = day < 10 ? `0${day}` : day
            h = h < 10 ? `0${h}` : h
            m = m < 10 ? `0${m}` : m
            s = s < 10 ? `0${s}` : s
            if (type) {
                return `${year}-${month}-${day} ${h}:${m}:${s}`;
            } else {
                return `${year}-${month}-${day}`;
            }

        },
        //实现全区引用loading
        $loading(flag) {
            if (flag) {
                this.$toast.loading("努力加载中...");
            } else {
                this.$toast.clear();
            }
        },
        $fail(err) {
            if (typeof err === 'object') {
                if (err.code !=603) {
                    this.$toast.fail(err.message);
                }
        
            } else {
                this.$toast.fail(err);
            }
        },
    },
}